# LapLeft with ACPI recipe for Fvwm-Crystal
# Written by Dominique Michel <dominique_libre@users.sourceforge.net>, 2014
#
# Modern laptops have a much wider than high screen. This recipie try to adress
# this issue by putting all the decorations on the left.
#
# You can use folding to navigate this file

Echo LapLeft with ACPI recipe loading from $.

# Place of the desktop icons; " ": left; "-": right {{{1
InfoStoreAdd DeskIconsSign "-"

# Includes and FVWM modules {{{1
# Default FVWM-Crystal functions, initialization {{{2
#Include components/functions/Window-Autohide
Include components/functions/FocusOnGotoPage

# Type of icons on the desktop {{{2
LoadPreferences IconsType

# Desktop manager {{{2
LoadPreferences DefaultDesktopManager

# Media player {{{2
Include components/functions/Music-$[infostore.MusicPlayer]

# Desktop settings {{{1
EdgeScroll			100000	100000
EdgeResistance			-1
Style * EdgeMoveDelay		250
Style * EdgeMoveResistance	20

HideGeometryWindow		Move, Resize
OpaqueMoveSize			100

# Change desktop with mouse wheel
Include components/bindings/Desktop-PageSwitch-Horizontal

# Pager {{{1
All (FvwmPager) Close
DestroyModuleConfig FvwmPager: *

# Desktop panel {{{1
EWMH-Desktop 63 3 3 3
EWMH-Panel-Bottom 3
EWMH-Panel-Top 3
EwmhBaseStruts 63 3 3 3

# Icons on Desktop {{{1 
Test (EnvMatch DefaultDesktopManager Crystal) PipeRead 'echo "Style * IconBox $(($[vp.width]-((((50*$[IconColumnsNumber]))+69))))x$(($[vp.height]-6))+50+6, IconFill right bottom, IconGrid 30 30"'
Test (!EnvMatch DefaultDesktopManager Crystal) Style * IconBox 66 3 -1 -1, IconFill right bottom, IconGrid 30 30

Style * StickyIcon
Style ApplicationPanel !Icon

DestroyFunc RedrawIconBox
AddToFunc RedrawIconBox
+ I PipeRead 'echo "Style * IconBox $(($[vp.width]-((((50*$[IconColumnsNumber]))+69))))x$(($[vp.height]-6))+50+6, IconFill right bottom, IconGrid 30 30"'

# top |Crystal + batt |---|ApplicationPanel|---|NotifArea| Clock  |Media|Freq + Temp + Pager| bottom #
# #   |     54px      |---|     490 px     |---| varianle|  24 px |48 px|       72 px       |#       #
# Crystal button {{{1
All (FvwmButtons-Crystal) Close
DestroyModuleConfig FvwmButtons-Crystal: *
*FvwmButtons-Crystal: Geometry 60x30+0+0
*FvwmButtons-Crystal: BoxSize smart
*FvwmVuttons-Crystal: ActiveColorset $[infostore.cs_panel_active]
*FvwmButtons-Crystal: Colorset $[infostore.cs_panel_inactive]
#*FvwmButtons-Crystal: Colorset $[infostore.cs_transparent]
*FvwmButtons-Crystal: Rows 1
*FvwmButtons-Crystal: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"
*FvwmButtons-Crystal: Padding 6 6
*FvwmButtons-Crystal: Frame 0
*FvwmButtons-Crystal: (1x1, Icon "22x22/fvwm-crystal/fvwm-crystal.png", \
	Action (Mouse 1) Menu /FVWM-Crystal $[MenuPosition_W], \
	Action (Mouse 2) Wallpaper-Random $[FVWM_SYSTEMDIR]/wallpapers $[FVWM_USERDIR]/wallpapers ~/wallpapers /usr/local/share/wallpapers /usr/share/wallpapers) \
  	Action (Mouse 4) X fvwm-crystal.videomodeswitch+, \
  	Action (Mouse 5) X fvwm-crystal.videomodeswitch-)

Module FvwmButtons FvwmButtons-Crystal

# AcpiBatt {{{1
All (FvwmButtons-BottomAcpiBatt) Close
DestroyModuleConfig FvwmButtons-BottomAcpiBatt: *
*FvwmButtons-BottomAcpiBatt: Geometry +0+30
*FvwmButtons-BottomAcpiBatt: BoxSize smart
*FvwmButtons-BottomAcpiBatt: ActiveColorset $[infostore.cs_panel_active
*FvwmButtons-BottomAcpiBatt: Colorset $[infostore.cs_panel_inactive]
*FvwmButtons-BottomAcpiBatt: Columns 2
*FvwmButtons-BottomAcpiBatt: Padding 2 2
*FvwmButtons-BottomAcpiBatt: Frame 0
*FvwmButtons-BottomAcpiBatt: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"
*FvwmButtons-BottomAcpiBatt: (2x1, Size 60 24, Swallow (Close, Respawn, FvwmModule) FvwmScript-AcpiBatt)"'
#PipeRead 'echo "*FvwmButtons-BottomAcpiBatt: (2x1, Size 60 `if [ $[panel_font_size] -lt 15 ]; then echo 24; else echo $(($[panel_font_size]*2)); fi`, Swallow (Close, Respawn, FvwmModule) FvwmScript-AcpiBatt)"'

Module FvwmButtons FvwmButtons-BottomAcpiBatt
Script components/scripts/FvwmScript-AcpiBatt

# Other menus  {{{1
# Applications menu generator
# This creates the main "Start Menu" avaiable at mouse button 1
PipeRead 'fvwm-crystal.apps --database=$[FVWM_DISTROMENUDIR]/Applications --database=$[FVWM_SYSTEMDIR]/Applications --database=$[FVWM_USERDIR]/Applications --search-icons-in=$[FVWM_USERDIR]/icons/$[infostore.Icon_Theme]/32x32/categories:$[FVWM_USERDIR]/icons/$[infostore.Icon_Theme]/32x32/apps:$[FVWM_SYSTEMDIR]/icons/$[infostore.Icon_Theme]/32x32/categories:$[FVWM_SYSTEMDIR]/icons/$[infostore.Icon_Theme]/32x32/apps:$[FVWM_DISTROMENUDIR]/icons/$[infostore.Icon_Theme]/32x32/categories:$[FVWM_DISTROMENUDIR]/icons/$[infostore.Icon_Theme]/32x32/apps --default-file-icon=32x32/apps/default.png --default-dir-icon=32x32/categories/directory.png --min-submenu-length=5 --root-cat-name="StartMenu" --sort=prio --no-panel --check-execs'
AddToMenu /StartMenu "" Nop
AddToMenu /StartMenu "%32x32/fvwm-crystal/fvwm-crystal.png%FVWM-Crystal" Popup /FVWM-Crystal

# This creates app menu available under Alt+Win_R
PipeRead 'fvwm-crystal.apps --database=$[FVWM_DISTROMENUDIR]/Applications --database=$[FVWM_SYSTEMDIR]/Applications --database=$[FVWM_USERDIR]/Applications --search-icons-in=$[FVWM_USERDIR]/icons/$[infostore.Icon_Theme]/22x22/categories:$[FVWM_USERDIR]/icons/$[infostore.Icon_Theme]/22x22/apps:$[FVWM_SYSTEMDIR]/icons/$[infostore.Icon_Theme]/22x22/categories:$[FVWM_SYSTEMDIR]/icons/$[infostore.Icon_Theme]/22x22/apps:$[FVWM_DISTROMENUDIR]/icons/$[infostore.Icon_Theme]/22x22/categories:$[FVWM_DISTROMENUDIR]/icons/$[infostore.Icon_Theme]/22x22/apps --default-file-icon=22x22/apps/default.png --default-dir-icon=22x22/categories/directory.png --min-submenu-length=5 --sort=prio --no-panel --check-execs'
AddToMenu /Applications '%22x22/fvwm-crystal/audio-x-generic.png%$[gt.Music]' Popup /Music

# Desktop menu with left click {{{1
SetEnv DesktopMenu /StartMenu
#SetEnv DesktopMenu /Applications
#SetEnv DesktopMenu /FVWM-Crystal

# Window list on mouse button 2 {{{2
Mouse 2 R $[Mod0] Window-List

# Application panel {{{1
All (ApplicationPanel) Close
DestroyModuleConfig ApplicationPanel: *
# geometry: Width(60) x Height(490) + x(0) + y( ( ( vp.H - ( 174 + 490 + ( ( fontsize * 3 ) / 2 ) + ( ( ( ( trayerwidth * 5 ) / 152 ) ) * 30 ) ) ) / 2 ) + 54 )
PipeRead 'echo "*ApplicationPanel: Geometry 60x490+0+$(((((($[vp.height]-((54+490+150+(((((((((((($trayer_width))/24))-1))/2))+1))*30))))))/2))+54))"'
*ApplicationPanel: BoxSize smart
*ApplicationPanel: ActiveColorset $[infostore.cs_panel_active]
*ApplicationPanel: Colorset $[infostore.cs_panel_inactive]
#*ApplicationPanel: Colorset $[infostore.cs_transparent]
*ApplicationPanel: Rows 10
*ApplicationPanel: Padding 6 2
*ApplicationPanel: Frame 0
*ApplicationPanel: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"

# This creates the main panel with applications - default app icon is
# shown on the panel, and can be launched using RMB; LMB opens the app

# category menu
PipeRead 'fvwm-crystal.apps --database=$[FVWM_DISTROMENUDIR]/Applications --database=$[FVWM_SYSTEMDIR]/Applications --database=$[FVWM_USERDIR]/Applications --without=/Applications/$[FVWM_DISTROMENUNAME] --search-icons-in=$[FVWM_USERDIR]/icons/$[infostore.Icon_Theme]/48x48/categories:$[FVWM_USERDIR]/icons/$[infostore.Icon_Theme]/48x48/apps:$[FVWM_SYSTEMDIR]/icons/$[infostore.Icon_Theme]/48x48/categories:$[FVWM_SYSTEMDIR]/icons/$[infostore.Icon_Theme]/48x48/apps:$[FVWM_DISTROMENUDIR]/icons/$[infostore.Icon_Theme]/48x48/categories:$[FVWM_DISTROMENUDIR]/icons/$[infostore.Icon_Theme]/48x48/apps --default-file-icon=48x48/apps/default.png --default-dir-icon=48x48/categories/directory.png --min-submenu-length=5 --sort=prio --panel-icons=topapp --panel-action1=menu --panel-action2=secondapp --panel-action3=topapp --menu-pos=W --menuname-suffix="Panel" --check-execs'

Module FvwmButtons ApplicationPanel

# Notification aera {{{1
# We use fixed sizes
# Settings of stalonetray
Test (!EnvMatch trayer_width 0) \
PipeRead 'if [ "$[infostore.NotificationAreaManager]" = "stalonetray" ]; then echo FvwmStalonePanel \
    30 2 $(((((((($[trayer_width]/24))-1))/2))+1)) "+0" "-+150" NE 60 $(((((((((((($trayer_width))/24))-1))/2))+1))*30)) "+0" "-+150"; fi'
# Settings of trayer
Test (!EnvMatch trayer_width 0) \
    PipeRead 'if [ "$[infostore.NotificationAreaManager]" = "trayer" ]; then echo FvwmTrayerPanel \
    pixel pixel $(((((((((((($trayer_width))/24))-1))/2))+1))*30)) bottom left 0 "150" \\"--width 60\\"; fi'

# Clock {{{1
All (FvwmButtons-Clock) Close
DestroyModuleConfig FvwmButtons-Clock: *
PipeRead 'echo \*FvwmButtons-Clock: Geometry 60x24+0-+126'
*FvwmButtons-Clock: BoxSize smart
*FvwmButtons-Clock: ActiveColorset $[infostore.cs_panel_active]
*FvwmButtons-Clock: Colorset $[infostore.cs_panel_inactive]
#*FvwmButtons-Clock: Colorset $[infostore.cs_transparent]
*FvwmButtons-Clock: Columns 2
*FvwmButtons-Clock: Padding 2 2
*FvwmButtons-Clock: Frame 0
*FvwmButtons-Clock: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"

*FvwmButtons-Clock: (2x1, \
Swallow (Close, Respawn, FvwmModule) "FvwmScript-Clock" 'Script components/scripts/FvwmScript-Clock', \
Action (Mouse 3) SendToModule *FvwmScript-Clock SendString 1 1 str)

Module FvwmButtons FvwmButtons-Clock

# Music panel {{{1 
All (FvwmButtons-Music) Close
DestroyModuleConfig FvwmButtons-Music: *
*FvwmButtons-Music: Geometry 60x48+0-78
*FvwmButtons-Music: BoxSize smart
*FvwmButtons-Music: ActiveColorset $[infostore.cs_panel_active]
*FvwmButtons-Music: Colorset $[infostore.cs_panel_inactive]
#*FvwmButtons-Music: Colorset $[infostore.cs_transparent]
*FvwmButtons-Music: Rows 2
*FvwmButtons-Music: Padding 7 2
*FvwmButtons-Music: Frame 0
*FvwmButtons-Music: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"

# Main music button , with some menus {{{2
*FvwmButtons-Music: (1x1, Size 22 22, Icon "22x22/categories/Multimedia.png", \
	Action (Mouse 1) Menu /Player $[MenuPosition_W], \
	Action (Mouse 2) Music-GUI, \
	Action (Mouse 3) Music-QJackGUI, \
	Action (Mouse 4) Mixer-Volume-Up $[infostore.Vol_Step], \
	Action (Mouse 5) Mixer-Volume-Down $[infostore.Vol_Step])
# music controls button {{{2
*FvwmButtons-Music: (1x1, Size 22 22, Icon "22x22/fvwm-crystal/media-eject.png", \
	Action (Mouse 1) Menu /Playlist-button $[MenuPosition_W], \
	Action (Mouse 2) Menu /Music/Volume $[MenuPosition_W], \
	Action (Mouse 3) Menu /Mixer $[MenuPosition_W], \
	Action (Mouse 4) Music-Next, \
	Action (Mouse 5) Music-Prev)
# music  controls button {{{2
*FvwmButtons-Music: (1x1, Size 22 22, Icon "22x22/fvwm-crystal/media-playback-start.png", \
    Action (Mouse 1) Music-Play, \
    Action (Mouse 2) Music-Pause, \
    Action (Mouse 3) Menu /Playback $[MenuPosition_W], \
	Action (Mouse 4) Music-Speed-Up, \
	Action (Mouse 5) Music-Speed-Down)
# music controls button 4 {{{2
*FvwmButtons-Music: (1x1, Size 22 22, Icon "22x22/fvwm-crystal/media-skip-forward.png", \
	Action (Mouse 1) Menu /Speed $[MenuPosition_W], \
	Action (Mouse 4) Button-Seek-+, \
	Action (Mouse 5) Button-Seek--)
# }}}2 
Module FvwmButtons FvwmButtons-Music

# CpuFreq  {{{1
All (FvwmButtons-BottomCpuFreq) Close
DestroyModuleConfig FvwmButtons-BottomCpuFreq: *
*FvwmButtons-BottomCpuFreq: Geometry +0-54
*FvwmButtons-BottomCpuFreq: BoxSize smart
*FvwmButtons-BottomCpuFreq: ActiveColorset $[infostore.cs_panel_active]
*FvwmButtons-BottomCpuFreq: Colorset $[infostore.cs_panel_inactive]
*FvwmButtons-BottomCpuFreq: Columns 3
*FvwmButtons-BottomCpuFreq: Padding 2 2
*FvwmButtons-BottomCpuFreq: Frame 0
*FvwmButtons-BottomCpuFreq: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"
*FvwmButtons-BottomCpuFreq: (3x1, Size 60 24, Swallow (Close, Respawn, FvwmModule) FvwmScript-CpuFreq)

Module FvwmButtons FvwmButtons-BottomCpuFreq
Script components/scripts/FvwmScript-CpuFreq-small

# CpuTemp {{{ 1
All (FvwmButtons-BottomCpuTemp) Close
DestroyModuleConfig FvwmButtons-BottomCpuTemp: *
*FvwmButtons-BottomCpuTemp: Geometry +0-30
*FvwmButtons-BottomCpuTemp: BoxSize smart
*FvwmButtons-BottomCpuTemp: ActiveColorset $[infostore.cs_panel_active]
*FvwmButtons-BottomCpuTemp: Colorset $[infostore.cs_panel_inactive]
*FvwmButtons-BottomCpuTemp: Columns 3
*FvwmButtons-BottomCpuTemp: Padding 2 2
*FvwmButtons-BottomCpuTemp: Frame 0
*FvwmButtons-BottomCpuTemp: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"
*FvwmButtons-BottomCpuTemp: (3x1, Size 60 24, Swallow (Close, Respawn, FvwmModule) FvwmScript-CpuTemp)

Module FvwmButtons FvwmButtons-BottomCpuTemp
Script components/scripts/FvwmScript-CpuTemp

#  Pager {{{1
All (FvwmButtons-Pager) Close
DestroyModuleConfig FvwmButtons-Pager: *
PipeRead "echo \*FvwmButtons-Pager: Geometry 60x30+0-0"
*FvwmButtons-Pager: BoxSize smart
*FvwmButtons-Pager: ActiveColorset $[infostore.cs_panel_active]
*FvwmButtons-Pager: Colorset $[infostore.cs_panel_inactive]
#*FvwmButtons-Pager: Colorset $[infostore.cs_transparent]
*FvwmButtons-Pager: Rows 1
*FvwmButtons-Pager: Padding 6 2
*FvwmButtons-Pager: Frame 0
*FvwmButtons-Pager: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"

# Pager button {{{2
*FvwmButtons-Pager: (1x1, Size 24 24, Icon "22x22/fvwm-crystal/user-desktop.png", \
Action (Mouse 2) GotoPage prev, \
Action (Mouse 3) GotoPage next \
Action (Mouse 4) GotoPage-Right, \
Action (Mouse 5) GotoPage-Left, \
Panel (right, position 15p) "FvwmPager" "Module FvwmPager")

# Pager window {{{2
DestroyFunc FvwmPagerWindow
AddToFunc FvwmPagerWindow
+ I KillModule FvwmPager
+ I DestroyModuleConfig FvwmPager: *
+ I PipeRead 'echo \*FvwmPager: Geometry $((60*$[infostore.Desk_Pages_X]))x$((60*$[infostore.Desk_Pages_Y]))+0-+0'
+ I *FvwmPager: MiniIcons
+ I *FvwmPager: Font none
+ I *FvwmPager: WindowBorderWidth 1
+ I *FvwmPager: Window3DBorders
#+ I *FvwmPager: NoSeparators
+ I *FvwmPager: UseSkipList
+ I *FvwmPager: Colorset * $[infostore.cs_panel_inactive]
+ I *FvwmPager: HilightColorset * $[infostore.cs_panel_active]
#+ I *FvwmPager: Colorset $[infostore.cs_transparent]
+ I *FvwmPager: HilightColorset $[infostore.cs_transparent]
+ I *FvwmPager: WindowColorsets $[infostore.cs_panel_wininactive] $[infostore.cs_panel_winactive]
#+ I *FvwmPager: WindowColorset $[infostore.cs_transparent] $[infostore.cs_transparent]

FvwmPagerWindow
Module FvwmButtons FvwmButtons-Pager

# Override FVWM style (it's applied later) {{{1
MenuStyle * PopupOffset 0 79
Style FvwmButtons-Clock Layer 2
# Style * TitleAtRight 

Echo /--------- Fvwm-Crystal: Recipe loaded ---------/
#PrintInfo infostore

# ViM modeline {{{1
# vim:foldmethod=marker:foldenable:foldlevel=0:ft=fvwm
